// pages/CustomizeCmpt/Behaviors/behaviors.js
var behaviorA = require('./behaviors/behaviors-a')
var behaviorB = require('./behaviors/behaviors-b')

Component({
  behaviors: [behaviorA, behaviorB],
  properties: { },
  data: { data: 'data-cmpt' },
  observers: {
    // observers-behavior-a、observers-behavior-b、observers-cmpt
    'prop, data': function(prop, data) { console.log('observers-cmpt') }
  },
  methods: {
    handleMethod: function() { console.log('methods-cmpt') },
    // 注册页面时，页面声明周期函数与页面监听函数写于此
    consoleLog: function() {
      console.log(this.properties.prop) // properties-behavior-b
      console.log(this.data.data) // data-cmpt
      this.handleMethod() // methods-cmpt

      this.setData({ data: 'new' })
    },
    handleSubmit(event) {
      console.log('submit', event.detail.value)
    },
    handleGetIns() {
      // {name: "BehaviorsComponentExport"}
      console.log('instance', this.selectComponent('.behaviors-component-export'))
    }
  },
  lifetimes: {
    // created-behavior-a、created-behavior-b、created-cmpt
    created: function() { console.log('created-cmpt') },
    // attached-behavior-a、attached-behavior-b、attached-cmpt
    attached: function() { console.log('attached-cmpt') },
    // detached-behavior-a、detached-behavior-b、detached-cmpt
    detached: function() { console.log('detached-cmpt') },
    // ...
  },
  pageLifetimes: {
    // show-behavior-a、show-behavior-b、show-cmpt
    show: function() { console.log('show-cmpt') },
    // hide-behavior-a、hide-behavior-b、hide-cmpt
    hide: function() { console.log('hide-cmpt') },
    // ...
  }
})
